package com.cn.lyl.util;

import java.io.*;

public class IO {

    public static File createNote(String realPath,String fileName){
        String path = realPath.split("out")[0]+"web\\note";

        File directory = new File(path);
        if(!directory.exists()){
            directory.mkdirs();
        }
        File file = new File(directory,fileName);
        if(!file.exists()){
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return file;

    }

    public static String readNote(File file){
        String result="";
        try {
            Reader reader = new FileReader(file);
            int leng = 0;
            while((leng=reader.read())!=-1){
                result += (char)leng;
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return result;
    }
}
